//forkz.c

#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>


void waitpidexit(int sig){
int status;
while(waitpid(-1,&status,WNOHANG)>0);
}
int i;
main(){
pid_t pid;
int state;
char *arglist[4];
scanf("%s %s %s",arglist[0],arglist[1],arglist[2]);
arglist[3]=0;
pid=execvp("ls",arglist);
(void) signal(SIGCHLD,waitpidexit);
pid=fork();
if(pid<0){
perror("error\n");
exit(1);
}
if(pid==0){
printf("pid is %ld\n,ppid is %ld\n",(long)getpid(),(long)getppid());
exit(0);
}
if(pid>0){
printf("pid is %ld\n,ppid is %ld\n",(long)getpid(),(long)getppid());
sleep(3);
kill(getppid(),SIGCHLD);
//system("ps -o pid,ppid,state,command");
//pid=execvp("ls",arglist);
    }
//(void) signal(SIGCHLD,waitexit);
system("ps -o pid,ppid,state,command");
//pause();
exit(0);
}